<?php

class Form_Signup extends Form_Custom_General {

    public function init() {

        $u_fname = $this->createElement('text', 'u_fname')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'First name should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->setAttribs(Array("placeholder" => "First name"));
        $this->addElement($u_fname);
		
		$u_lname = $this->createElement('text', 'u_lname')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Name should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->setAttribs(Array("placeholder" => "Last name"));
        $this->addElement($u_lname);

        
		$u_orgname = $this->createElement('text', 'u_orgname')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Name should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->setAttribs(Array("placeholder" => "Organization name"));
        $this->addElement($u_orgname);
		
        $email = $this->createElement('text', 'email')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Email address should not be blank.')))
                ->addValidator(new Zend_Validate_EmailAddress())
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->setAttribs(Array('class' => "span12", "placeholder" => "E-mail address"));
        $email->getValidator('emailAddress')->setMessage("Email address is not valid.", Zend_Validate_EmailAddress::INVALID_FORMAT);
        $this->addElement($email);
        
        
        $minPwdValidator = new Zend_Validate_StringLength(array('min' => 6));
        $minPwdValidator->setMessage('Password should be minimum of 6 characters.');
        $password = $this->createElement('password', 'password')
                ->setRequired(TRUE)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Password should not be blank.')))
                ->addValidator($minPwdValidator, true)
                ->setAttribs(Array('class' => "span12", "placeholder" => "Password"));
        $this->addElement($password);

        $confirmpassword = $this->createElement('password', 'user_confirmpassword')
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Confirm password should not be blank.')))
                ->setAttribs(Array('class' => "span12", "placeholder" => "Confirm password"));
        $this->addElement($confirmpassword);
    }

}